Re: is it possible to store results of aggregate calculations in table fields?
От | Daniel Staal |
---|---|
Тема | Re: is it possible to store results of aggregate calculations in table fields? |
Дата | |
Msg-id | A6529F3D76247FEA7618D8F9@[192.168.1.50] обсуждение исходный текст |
Ответ на | is it possible to store results of aggregate calculations in table fields? (Jude DaShiell <jdashiel@panix.com>) |
Список | pgsql-novice |
--As of October 13, 2014 4:49:28 PM -0400, Jude DaShiell is alleged to have said: > If I can do that and use table field values to do calculations once moved > it won't be necessary for me to use plr. Earlier I tried: > max_cystalic_pressure int NOT NULL, default max(cystalic_pressure), > and psql won't create the table complaining about default and DEFAULT and > def_EXPR I intended to be max(cystalic_pressure). > Unfortunately Linux command line environment hasn't got anything able to > compete with excel in terms of excel's functions which is why I tried > this database system at all. I hope I do not have to use Windows to get > this done. --As for the rest, it is mine. You could probably get the effect with a trigger, but I have a question for you: If their is a new max cystalic_pressure, do you want the table to update all the values? If so, how often do you want to check? At that point you are starting to get really convoluted. Probably a better option (especially if you want to have it update anytime the data changes) would be to create a VIEW. Views operate like tables in most respects to the user, but run a query instead of operating on a pre-existing table. On the other hand, I'm still wondering why you'd want to store that aggregate in every entry. It sounds like a XY[1] problem to me, so I wonder what you are really trying to solve. ;) Daniel T. Staal [1]: <http://xyproblem.info/> --------------------------------------------------------------- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. ---------------------------------------------------------------
В списке pgsql-novice по дате отправления: